{itemplate 'public/header'}
{if $ta == 'detail'}
<div class="page order-info">
	<header class="bar bar-nav common-bar-nav">
		<a class="icon icon icon-arrow-left pull-left back" href="javascript:;"></a>
		<h1 class="title">{$store['title']}({$order['order_type_cn']})</h1>
		<a class="pull-right refresh" href="javascript:;">刷新</a>
	</header>
	{if $order['status'] < 5}
	<nav class="bar bar-tab footer-bar">
		{if $order['status'] == 1}
			<a href="{php echo imurl('manage/order/tangshi/status', array('id' => $order['id'], 'type' => 'handle'))}" class="tab-item js-post"  data-confirm="确定接单吗?"> 确认接单</a>
		{elseif $order['status'] == 2}
			<a href="{php echo imurl('manage/order/tangshi/status', array('id' => $order['id'], 'type' => 'end'))}" class="tab-item js-post"  data-confirm="确定完成订单吗?">完成订单</a>
		{/if}
		{if $order['is_pay'] == 1 && $order['pay_type'] != 'delivery'}
		<a href="{php echo imurl('manage/order/tangshi/cancel', array('id' => $order['id']));}" class="tab-item js-post" data-confirm="确定取消订单并退款?">取消订单并退款</a>
		{else}
		<a href="{php echo imurl('manage/order/tangshi/cancel', array('id' => $order['id']));}" class="tab-item js-post" data-confirm="确定取消订单?">取消订单</a>
		{/if}
		<a href="javascript:;" class="tab-item order-other" data-id="{$order['id']}" data-pay="{$order['is_pay']}" data-pay-type="{$order['pay_type']}"> 更多</a>
	</nav>
	{/if}
	<div class="content">
		<div class="buttons-tab">
			<a href="#order-detail" class="tab-link active button">订单详情</a>
			<a href="#order-status" class="tab-link button">订单状态</a>
			{if $order['refund_status'] > 0}
				<a href="#order-refund" class="tab-link button">退款详情</a>
			{/if}
		</div>
		<div class="tabs">
			<div id="order-detail" class="tab active">
				<div class="order-state border-1px-tb">
					<div class="order-state-con">
						<div class="guide">
							<img src="{WE7_WMALL_TPL_URL}static/img/order_status_service.png" alt="" />
						</div>
						<div class="order-state-detail">
							<div class="clearfix">订单{$order_status[$order['status']]['text']}<span class="pull-right date">{php echo date('H:i', $order['addtime']);}</span></div>
							<div class="tips clearfix">{$log['note']}</div>
						</div>
					</div>
				</div>
				<div class="content-block-title">订单明细</div>
				<div class="order-details">
					<div class="order-details-con border-1px-tb">
						<div class="store-info border-1px-b">
							<a href="{php echo imurl('wamll/store/goods/index',array('sid' => $order['sid']));}" class="external">
								<img src="{php echo tomedia($store['logo']);}" alt="" />
								<span class="store-title">{$store['title']}</span>
								<span class="icon icon-arrow-right pull-right"></span>
							</a>
						</div>
						<div class="inner-con border-1px-b">
							{if !empty($order['note'])}
								<div class="row order-note">
									<span class="color-danger">备注: </span>{$order['note']}
								</div>
							{/if}
							{loop $goods $good}
								<div class="row no-gutter">
									{if $good['bargain_id'] > 0}
										<div class="col-55 icon-before">
											<img src="{WE7_WMALL_TPL_URL}static/img/zhe_b.png">
											{$good['goods_title']}
										</div>
									{else}
										<div class="col-55">
											{$good['goods_title']}
										</div>
									{/if}
									<div class="col-10 text-right color-muted {if $good['goods_num'] > 1}color-danger{/if}">×{$good['goods_num']}</div>
									<div class="col-35 text-right color-black">
										{if $good['bargain_id'] > 0}
											<span class="color-muted text-line-through">¥{$good['goods_original_price']}</span>
										{/if}
										￥{$good['goods_price']}
									</div>
								</div>
							{/loop}
						</div>
						<div class="inner-con border-1px-b">
							<div class="row no-gutter">
								<div class="col-80">服务费</div>
								<div class="col-20 text-right color-black">￥{$order['serve_fee']}</div>
							</div>
							<div class="row no-gutter">
								<div class="col-80">平台抽取佣金</div>
								<div class="col-20 text-right color-black">-￥{$order['plateform_serve_fee']}</div>
							</div>
							<div class="row no-gutter">
								<div class="col-80">商户优惠活动</div>
								<div class="col-20 text-right color-black">-￥{$order['store_discount_fee']}</div>
							</div>
							<div class="row no-gutter">
								<div class="col-80">平台补贴</div>
								<div class="col-20 text-right color-black">+￥{$order['plateform_discount_fee']}</div>
							</div>
						</div>
						<div class="inner-con border-1px-b">
							<div class="row no-gutter">
								<div class="col-60 color-muted">顾客实际支付 <span class="color-black">￥{$order['final_fee']}</span></div>
								<div class="col-20 text-right color-muted">实际入账</div>
								<div class="col-20 text-right color-black">￥{$order['store_final_fee']}</div>
							</div>
						</div>
					</div>
					<div class="order-pay-info {$order['pay_type_class']}"></div>
				</div>
				{if !empty($activityed)}
					<div class="content-block-title">优惠详情</div>
					<div class="list-block order-details-con">
						<div class="inner-con border-1px-b">
							{loop $activityed $row}
							<div class="row no-gutter">
								<div class="col-80 icon-before">
									<img src="{WE7_WMALL_TPL_URL}static/img/{$row['icon']}" alt=""/>
									{$row['name']}
								</div>
								<div class="col-20 text-right color-black">{$row['note']}</div>
							</div>
							{/loop}
						</div>
					</div>
				{/if}
				<div class="content-block-title">其他信息</div>
				<div class="list-block other-info">
					<ul class="border-1px-tb">
						<li class="item-content">
							<div class="item-inner border-1px-b">
								<div class="item-title">商户订单号</div>
								<div class="item-after">{$order['serial_sn']}</div>
							</div>
						</li>
						<li class="item-content">
							<div class="item-inner border-1px-b">
								<div class="item-title">平台订单号</div>
								<div class="item-after">{$order['ordersn']}</div>
							</div>
						</li>
						{if $order['order_type'] == 3}
							<li class="item-content">
								<div class="item-inner border-1px-b">
									<div class="item-title">桌台号</div>
									<div class="item-after">{$order['table']['title']}号桌</div>
								</div>
							</li>
						{/if}
						{if $order['order_type'] == 4}
							<li class="item-content">
								<div class="item-inner border-1px-b">
									<div class="item-title">预定时间</div>
									<div class="item-after">{$order['reserve_time']}</div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-inner border-1px-b">
									<div class="item-title">桌台</div>
									<div class="item-after">{$table_categorys[$order['table_cid']]['title']}</div>
								</div>
							</li>
							<li class="item-content">
								<div class="item-inner border-1px-b">
									<div class="item-title">预定类型</div>
									<div class="item-after">{$order['reserve_type_cn']}</div>
								</div>
							</li>
						{/if}
						<li class="item-content">
							<div class="item-inner border-1px-b">
								<div class="item-title">支付方式</div>
								<div class="item-after">{$order['pay_type_cn']}</div>
							</div>
						</li>
						<li class="item-content">
							<div class="item-inner">
								<div class="item-title">发票信息</div>
								<div class="item-after">{if empty($order['invoice'])}无{else}{$order['invoice']}{/if}</div>
							</div>
						</li>
					</ul>
				</div>
			</div>
			<div id="order-status" class="tab">
				{loop $logs $key $log}
				<div class="order-status-item">
					<div class="guide">
						{if $maxid != $key}
						<img src="{WE7_WMALL_TPL_URL}static/img/order_status_service_grey.png" alt="" />
						{else}
						<img src="{WE7_WMALL_TPL_URL}static/img/order_status_service.png" alt="" />
						{/if}
					</div>
					<div class="order-status-info">
						<div class="arrow-left"></div>
						<div class="clearfix">{$log['title']} <span class="time pull-right">{php echo date('H:i', $log['addtime'])}</span></div>
						<div class="tips">{$log['note']}</div>
					</div>
				</div>
				{/loop}
			</div>
			<div id="order-refund" class="tab">
				<div class="refund-detail">
					<div class="row no-gutter refund-de-title">
						<div class="col-60">退款金额<span class="color-danger">¥{$refund['fee']}</span></div>
						<div class="col-40"><span>{$refund['refund_status_cn']}</span></div>
					</div>
					<div class="refund-detail-con">
						<div class="row no-gutter">订单编号:<span>{$order['ordersn']}</span></div>
						<div class="row no-gutter">退款周期:<span>1-15个工作日</span></div>
						<div class="row no-gutter">支付方式:<span>{$order['pay_type_cn']}</span></div>
						{if !empty($refund['refund_channel'])}
						<div class="row no-gutter">退款方式:<span>{$refund['refund_channel_cn']}</span></div>
						{/if}
						{if !empty($refund['refund_account'])}
						<div class="row no-gutter">退款账户:<span>{$refund['refund_account']}</span></div>
						{/if}
					</div>
				</div>
				<div class="refund-plan">
					{loop $refund_logs $key $log}
					<div class="order-refund-item">
						<div class="guide">
							{if $refundmaxid != $key}
							<img src="{WE7_WMALL_TPL_URL}static/img/order_status_service_grey.png" alt="" />
							{else}
							<img src="{WE7_WMALL_TPL_URL}static/img/order_status_service.png" alt="" />
							{/if}
						</div>
						<div class="order-refund-info">
							<div class="arrow-left"></div>
							<div class="clearfix">{$log['title']} <span class="time pull-right">{php echo date('H:i', $log['addtime'])}</span></div>
							<div class="tips">{$log['note']}</div>
						</div>
					</div>
					{/loop}
				</div>
			</div>
		</div>
	</div>
</div>
{/if}

<script>
	$(function(){
		function order_print(id){
			if(!id) {
				return false;
			}
			$.showPreloader('系统处理中。。。');
			$.post("{php echo imurl('manage/order/tangshi/print')}", {id: id}, function(data){
				var result = $.parseJSON(data);
				if(result.message.errno != 0) {
					$.toast(result.message.message);
				} else {
					$.toast('打印成功');
				}
			});
		}

		function order_cancel(id, is_pay, pay_type){
			if(!id) {
				return false;
			}
			var tips = '确定取消该订单吗';
			if(is_pay == 1 && pay_type != 'deliveryer' && pay_type != 'cash') {
				var tips = '该订单已支付, 取消订单将发起退款流程, 确定取消订单吗';
			}
			$.confirm(tips, function(){
				$.showPreloader('系统处理中。。。');
				$.post("{php echo imurl('manage/order/tangshi/cancel')}", {id: id}, function(data){
					var result = $.parseJSON(data);
					if(result.message.errno != 0) {
						$.toast(result.message.message);
					} else {
						$.toast('取消订单成功', location.href);
					}
				});
				return;
			});
		}

		$(document).on("click", ".order-other", function() {
			var id = $(this).data('id');
			if(!id) {
				return false;
			}
			var is_pay = $(this).data('pay');
			var pay_type = $(this).data('pay-type');
			var buttons1 = [
				{text: '请选择', label: true},
				{text: '打印订单', bold: true, onClick: function(){order_print(id)}},
				{text: '取消订单', bold: true, onClick: function(){order_cancel(id, is_pay, pay_type)}}
			];
			var buttons2 = [
				{text: '取消', bg: 'danger'}
			];
			var groups = [buttons1, buttons2];
			$.actions(groups);
			return false;
		});
	})
</script>
{itemplate 'public/footer'}